package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	GoodsTitle  string  `gorm:"type:varchar(30);not null;"`
	GoodsPrice  float64 `gorm:"type:decimal(10,2);not null;"`
	GoodsCover  string  `gorm:"type:varchar(255);not null;"`
	GoodsStock  int64   `gorm:"type:int;not null;"`
	GoodsStatus int64   `gorm:"type:int; not null;"`
	Checked     int64   `gorm:"int;default:1;not null;'"`
}

/*type Cart struct {
	gorm.Model
	GoodsId    int64   `gorm:"type:int;"`
	GoodsTitle string  `gorm:"type:varchar(30);"`
	GoodsPrice float64 `gorm:"type:decimal(10,2);"`
	Num        int64   `gorm:"type:int;"`
	Checked    int64   `gorm:"int;default:1;not null;'"`
}*/

func (g *Goods) FindGoods(goodsId int64) error {
	return DB.Debug().Where("id=?", goodsId).Find(&g).Error
}

func (g *Goods) Create() error {
	return DB.Debug().Create(&g).Error
}
